<template>
    <div class="tab">
        <van-image
                round
                width="3rem"
                height="3rem"
                src="https://img01.yzcdn.cn/vant/cat.jpeg"
                
        />
        <van-form @submit="onSubmit">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit" @click="onSubmit">登录</van-button>
            </div>
            <div class="reg">
                <div @click="toRegister">没有账号？立即注册</div>
            </div>
        </van-form>
    </div>
</template>

<script>
 import { Toast } from 'vant';
 import axios from 'axios'
 import {GoLogin} from '@/request/api'
    export default {
        name: "Login",
        data() {
            return {
                username: '',
                password: '',
            };
        },
        methods: {
            onSubmit(values) {
                //console.log('username', values['用户名']);
                //console.log('password', values['密码']);
                let uname=values['用户名']
                let upwd=values['密码'] 
                GoLogin({
                  uname,
                  upwd
                }).then(res=>{
                  if(res.errno == 0){
                    console.log(res.data)
                  }
                })
            },
            toRegister(){
                this.$router.push('/register')
            },
        }
    }

</script>

<style scoped>
   
   .van-image.van-image--round{
       left:45%;
       top:13px;
   }
   .van-cell{
       margin-top:10px;
       box-sizing: border-box;
   }
   .reg{
       margin-left:15px;
       color:#323233;
   }
   .tab{
       margin-top:50%;
   }
</style>

